c# how to delete all files in directory

60

how to delete all files in a directory c# -

System.IO.DirectoryInfo di = new DirectoryInfo("YourPath");

foreach (FileInfo file in di.GetFiles())
{
    file.Delete(); 
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
    dir.Delete(true); 
}

How to delete folder with files on c# -

Directory.Delete(@"folderPath", true);

Comments

Submit
0 Comments